<body>
    <div class="x-body">
        <form class="layui-form">
            <input type="hidden" name="key" value="{$key}"> 
            <div class="layui-form-item">
                <label for="id" class="layui-form-label">
                    ID
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="id" name="id"
                    autocomplete="off"  value="{$id}" disabled="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="ctitle" class="layui-form-label">
                    <span class="x-red">*</span>分类名
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="ctitle" name="ctitle" value="{$ctitle}" required="" lay-verify="required"
                    autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                </label>
                <button  class="layui-btn" lay-filter="save" lay-submit="">
                    保存
                </button>
            </div>
        </form>
    </div>
    <script>
        layui.use(['form','layer'], function(){
            $ = layui.jquery;
          var form = layui.form()
          ,layer = layui.layer;
        

          //监听提交
          form.on('submit(save)', function(data){
            //发异步，把数据提交给php
            $.post('{:U('admin/admin/cate_edit')}', {data: data.field}, function(response) {
                if (response.editdata) {
                    layer.alert(response.info, {icon: 6},function () {
                        // 获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                        parent.document.children[0].children[1].children[2].children[2].children[1].children[response.key].children[2].innerText = response.editdata.ctitle;
                    });
                } else {
                    layer.alert(response.info, {icon: 5});
                }
            });
            return false;
          });
          
          
        });
    </script>
</body>